package com.harmontronics.hanma.paas.paas.utils;

import com.harmontronics.hanma.paas.paas.consts.BaseI18nKeyEnum;
import com.harmontronics.hanma.paas.paas.exception.ErrorKeyException;
import org.springframework.validation.BindingResult;

/**
 * @author ldb
 */
public class ParamUtils {

    /**
     * 验证参数
     * @param bindingResult
     */
    public static void valid(BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            throw new ErrorKeyException(BaseI18nKeyEnum.findByI18nKey(bindingResult.getFieldError().getDefaultMessage()),bindingResult.getFieldError().getField());
        }
    }


}
